package com.example.zhuzehua.service;

import com.example.zhuzehua.dao.TbUserDAO;
import com.example.zhuzehua.entity.TbGoods;
import com.example.zhuzehua.entity.TbUser;
import com.example.zhuzehua.entity.TbUserinfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbUserServiceImpl implements  TbUserService {
    @Autowired
    private TbUserDAO tbUserDAO;

    @Override
    public List<TbUser> findAll() {
        return tbUserDAO.fundAll();
    }

    @Override
    public String add(TbUser user) {
        int status = tbUserDAO.add(user);
        if (status > 0) {
            return "插入成功";
        } else {
            return "插入失败";
        }
    }

    @Override
    public String updateUser(TbUser user) {
        int status = tbUserDAO.updateUser(user);
        if (status > 0) {
            return "更新成功";
        } else {
            return "更新失败";
        }
    }

    @Override
    public String delUser(int id) {
        int status = tbUserDAO.delUser(id);
        if (status > 0) {
            return "删除成功";
        } else {
            return "删除失败";
        }
    }

    @Override
    public List<TbUser> queryByName(TbUser user) {
        return tbUserDAO.queryByName(user);
    }

    @Override
    public List<TbUser> queryLikeName(TbUser user) {
        return tbUserDAO.queryLikeName(user);
    }

    @Override
    public List<TbUser> queryTiaojiao(TbUser user) {
        return tbUserDAO.queryTiaojiao(user);
    }

    @Override
    public String login(TbUserinfo userinfo) {
        if (tbUserDAO.login(userinfo)!=null){
            return "登录成功";
        }
        else {
            return "登录失败";
        }
    }

    @Override
    public List<TbUser> findAllFenye(int pageNum, int pageSize) {
        return tbUserDAO.findAllFenye((pageNum-1)*pageSize,pageSize);
    }

    @Override
    public List<TbGoods> findAllWendu() {
        return tbUserDAO.findAllWendu();
    }

    @Override
    public List<TbGoods> findAllGoodsByType(int type) {
        return tbUserDAO.findAllGoodsByType(type);
    }
}


